package com.sqx.modules.datacentre.controller.app;

import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.app.entity.UserEntity;
import com.sqx.modules.app.service.UserService;
import com.sqx.modules.errand.entity.Feedback;
import com.sqx.modules.sys.entity.SysUserEntity;
import com.sqx.modules.sys.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value = "用户端-用户信息", tags = {"用户端-用户信息"})
@RequestMapping(value = "/app/user")
public class UserMessageController {

    @Autowired
    private UserService userService;

    @Autowired
    private SysUserService sysUserService;

    @Login
    @ApiOperation("查看用户信息")
    @GetMapping(value = "/selectUserMessageNew")
    public com.sqx.modules.health.common.Result selectUserMessageNew(@RequestAttribute Long userId){
        SysUserEntity entity = sysUserService.getById(userId);
        return com.sqx.modules.health.common.Result.success(entity);
        //return userService.selectUserMessage(userId);
    }

    @Login
    @ApiOperation("查看用户信息")
    @GetMapping(value = "/selectUserMessage")
    public Result selectUserMessage(@RequestAttribute Long userId){

        return userService.selectUserMessage(userId);
    }

    @Login
    @ApiOperation("修改用户信息")
    @PostMapping(value = "/updateUserMessage")
    public Result updateUserMessage(@RequestAttribute Long userId, @RequestBody UserEntity userEntity){
        userEntity.setUserId(userId);
        return userService.updateUserMessage(userEntity);
    }

    @Login
    @PostMapping(value = "/userFeedback")
    @ApiOperation("用户反馈")
    public Result userFeedback(@RequestAttribute Long userId, @RequestBody Feedback feedback){

        return userService.userFeedback(userId, feedback);
    }

}
